package com.xqgl.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xqgl.bean.Property;
import com.xqgl.service.PropertyDaoImp;

/**
 * Servlet implementation class addPropertyServlet
 */
@WebServlet("/addPropertyServlet")
public class addPropertyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addPropertyServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;Charset=utf-8");
		String villagename = request.getParameter("villagename");
		String buildingname = request.getParameter("buildingname");
		String hpronum = request.getParameter("hpronum");
		String hproname = request.getParameter("hproname");
		String username = request.getParameter("username");
		int userphone = Integer.parseInt(request.getParameter("userphone"));
		int room = Integer.parseInt(request.getParameter("room"));
		int bunit = Integer.parseInt(request.getParameter("bunit"));
		int layer = Integer.parseInt(request.getParameter("layer"));
		String hprodesc = request.getParameter("hprodesc");
		String livetime = request.getParameter("livetime");
		Property property = new Property();
		property.setVillagename(villagename);
		property.setBuildingname(buildingname);
		property.setHpronum(hpronum);
		property.setHproname(hproname);
		property.setUsername(username);
		property.setUserphone(userphone);
		property.setRoom(room);
		property.setBunit(bunit);
		property.setLayer(layer);
		property.setHprodesc(hprodesc);
		property.setLivetime(livetime);
		PropertyDaoImp imp = new PropertyDaoImp();
		try {
			imp.add(property);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("hprolist.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
